/*
 * FileTransporter.h
 *
 *  Created on: Apr 8, 2011
 *      Author: sms103
 */

#ifndef FILETRANSPORTER_H_
#define FILETRANSPORTER_H_

#include "SFTPConnection.h"
#include "SFTPMessage.h"
#include "../shared/ParamParser.h"
#include "SFTPTransportSocket.h"
#include "EmulatedNetworkSocket.h"

#include <iostream>
#include <fstream>
#include <string>

#include <sys/types.h>
#include <sys/time.h>
#include <dirent.h>
#include <errno.h>
#include <list>

#define DIRENT_TYPE_FILE 8
#define DIRENT_TYPE_DIR 4

using namespace std;

class FileTransporter {
public:
	FileTransporter(SFTPConnection *conn);

	//sends the local file specified by filename through the
	//SFTPConnection this object was constructed on
	bool sendFile(string filename);

	//receives a file through the SFTPConnection and writes
	//it to the local file specified by filename
	bool recvFile(string filename);


	bool sendDirectoryContents(string pathname);

	//puts contents into contents object and returns true for success
	bool recvDirectoryContents(string& contents);


	int getDirContent(string dir, list<string> &files);

	virtual ~FileTransporter();

private:
	SFTPConnection *dataConn;

	SFTPMessage * msg;
	string statsFileName;


};

#endif /* FILETRANSPORTER_H_ */
